<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 将对象中的两个数组使用for...of进行遍历
        let obj = {
            arr:['one','two','three','four'],
            arr2:["老王","老李","老高"],
        }

        Object.prototype[Symbol.iterator] = function(){
            // let this
            let arr = [...this.arr,...this.arr2]; 
            // console.log(arr); //['one', 'two', 'three', 'four', '老王', '老李', '老高']

            let index = 0;
            return {
                next:()=>{
                    return {
                        value:arr[index],
                        done:index++>=arr.length
                    }
                }
            }
        }


        for(let item of obj){
            // 循环7次 
            // 每次的值 都是数组的val
            console.log(item);
        }
    </script>
</body>
</html>